<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>待处理管理</title> <#include "/common/resource.ftl">
<style type="text/css">
    .panel-body{background: #eaedef;}
    .panel-header{background: #fafafa;}
    .tabs-header, .tabs-tool {background-color: #Fafafa;}
	.datagrid .panel-body {background: #fff;}
	.datagrid-header-row, .datagrid-row {height: 25px;}
	.panel-toolbar{background: #fff;overflow: hidden;}
	.panel-toolbar .toolbar-left{margin-left: 10px;height: 100%;float: left;}
	.panel-toolbar .toolbar-left .toolbar-item {float: left;padding-top: 10px;padding-left: 5px;}
	.toolbar-right{margin-right: 10px;height: 100%;float: right;padding-top: 10px;}
	.panel-toolbar .toolbar-left .toolbar-item .form-control{border: 1px solid #ccc;border-radius:3px; font-size: 9pt;height: 27px;width:200px;padding-top: 0;padding-bottom: 0px;padding-right: 0;padding-left: 5px;}
	.panel-toolbar .toolbar-left .toolbar-item .form-control:focus{border: 1px solid #1E9FFF;}
    </style>
<script type="text/javascript">
	var getSearchParams = function() {
		return {
			name : $("input[name='name']").val() || "",
		};
	}
</script>
</head>
<body  class="easyui-layout" fit="true" border="false">
  <div data-options="region:'north'" border="false" style="height: 86px;padding: 10px;padding-bottom: 0px;">
	<div class="easyui-panel panel-toolbar" title="指令列表" border="true" fit="true" style="border-bottom: none;">
       		<div class="toolbar-left">
       			<div class="toolbar-item">
                       <input id="keyword" name="searchInput" type="text" class="form-control" placeholder="指令标题、关键字">
                   </div>
                   <div class="toolbar-item">
                       <button class="layui-btn layui-btn-small layui-btn-normal search-button" style="border-radius: 3px;"><i class="fa fa-search"></i> 查询</button>
                   </div>
       		</div>
       		<div class="toolbar-right">
       			
       			<div class="layui-btn-group">
                    <button class="layui-btn layui-btn-normal sign-button"	reurl="${params.contextPath}/web/instructionTask/sign.json">
						<i class="fa fa-plus"></i>签收
					</button>
					<button class="layui-btn layui-btn-normal feedback-button"	p="url:'${params.contextPath}/view/icip/instruction/instruction_feedback.htm',title:'指令反馈',width:'90%',height:'95%'">
						<i class="fa fa-pencil"></i>反馈
					</button>
				</div>
       		</div>
       	</div>
	</div>
	<div data-options="region:'center'" border="false" style="padding: 10px;padding-bottom: 4px;padding-top: 0px;">
		<table id="datagrid"
			options="url:'${params.contextPath}/web/instructionTask/undoList.json',params:'getSearchParams',dblClickRow:'showDetail',fit:true,onSelect:showFeedback,onLoadSuccess:loadSuccess">
			<thead>
				<tr>
					
					<th data-options="field:'stateStr',width:100,formatter:formatHandleState">处理状态</th>
					<th data-options="field:'title',width:150,formatter:formatInstructionValue">指令标题</th>
					<th data-options="field:'keyword',width:120,formatter:formatInstructionValue">关键字</th>
					<th data-options="field:'typeStr',width:80,formatter:formatInstructionValue">指令类型</th>
					<th data-options="field:'senderName',width:60,formatter:formatInstructionValue">签发人</th>
					<th data-options="field:'senderOrgName',width:100,formatter:formatInstructionValue">签发单位</th>
					<th data-options="field:'sendTimeStr',width:100,formatter:formatInstructionValue">发布时间</th>
					<th data-options="field:'_count',width:150,formatter:formatStatistic">指令统计</th>

				</tr>
			</thead>
		</table>
	</div>
<div data-options="region:'south'" border="false" style="padding: 10px;height: 35%;padding-top: 0px;">
		<div class="easyui-tabs" fit="true">
			<div title="反馈列表" style="padding:4px;background: #fff; ">
				<table id="datagrid-feedback" data-options="fitColumns:true,fit:true,onDblClickRow:showFeedbackDetail" >
			        <thead>
			            <tr>
			            	<th data-options="field:'orgName',width:120">反馈标题</th>
			            	<th data-options="field:'orgName2',width:120">信息报送模板</th>
			            	<th data-options="field:'senderName',width:60">反馈人</th>
			            	<th data-options="field:'senderOrgName',width:80">反馈单位</th>
			                <th data-options="field:'sendTimeStr',width:100">反馈时间</th>
			            </tr>
			        </thead>
		    	</table>
		    </div>
		    <div title="处理日志列表" style="padding:4px;background: #fff; ">
				<table id="datagrid-log" data-options="fitColumns:true,fit:true" >
			        <thead>
			            <tr>
			            	<th data-options="field:'orgName',width:60">处理类型</th>
			            	<th data-options="field:'stateStr',width:150">处理内容</th>
			            	<th data-options="field:'stateStr22',width:60">处理人</th>
			            	<th data-options="field:'stateStr444',width:100">处理单位</th>
			            	<th data-options="field:'signTimeStr',width:100">处理时间</th>
			            </tr>
			        </thead>
		    	</table>
		    </div>
		 </div>
		
	</div>
</body>
<script type="text/javascript">
	$(function() {
		
		$(".sign-button").click(function() {
			var ids = DataGrid.getSelectId();
			if (ids == "") {
				layer.msg("请选择要签收的指令")
				return false;
			}
			var url = $(this).attr("reurl");
			var row = DataGrid.getSelectRow();
			if(row.state==2 || row.state==3){
				layer.msg("该指令已签收,不可再次签收");
			    return false;
			}else {
				layer.confirm('确定签收该指令吗?', function() {
					$.ajaxRequest({
						url : url,
						data : { ids : ids },
						success : function(data) {
							$.message(data.message);
							if (data.success) {
								DataGrid.reload();
							}
						}
					});
				});
			}
		});

		$(".feedback-button").click(function() {
			var ids = DataGrid.getSelectId();
			if (ids == "") {
				layer.msg("请选择要反馈的指令")
				return false;
			}
			DialogManager.singleSelected2($(this),function(row,params){
			if(row.state==1){
				layer.msg("该指令为待签收,不可反馈");
			    return false;
			}
			params.url = $.getUrl(params.url, "taskid", row.id);
			params.url = $.getUrl(params.url, "instructionid", row.instruction.id);
			return true;

			});
			
		});

	});
	
	function loadSuccess(){
		$("#datagrid").datagrid("selectRow",0);
	}


	function showFeedback(){
		var id = DataGrid.getSelectId();
		
		$("#datagrid-feedback").datagrid({
			url:'${params.contextPath}/web/instructionTask/list.json?instructionid='+id
		});
		
		$("#datagrid-log").datagrid({
			url:'${params.contextPath}/web/instructionTask/list.json?instructionid='+id
		});
	}
	
	function showFeedbackDetail(index, row){
		var url = "${params.contextPath}/view/icip/instruction/instruction_feedback_detail.htm?id=" + row.id;
	    DialogManager.openDialog("url:'" + url + "',title:'指令反馈详情',width:'90%',height:'95%'");
	}
	
	function formatHandleState(val, row) {

		if (row.state == 1) {
			return '<span class="ui-stop">' + val + '</span>';
		} else if (row.state == 2) {
			return '<span class="ui-stop">' + val + '</span>';
		} else if (row.state == 3) {
			return '<span class="ui-accept">' + val + '</span>';
		}
		return val;
	}

	function formatInstructionValue(val, row) {
		return row.instruction[this.field];
	}

	function formatStatistic(val, row) {

		return '<span class="ui-accept" >反馈[3]</span>'
				+ '&nbsp;<span class="ui-accept">日志[3]</span>';

	}
	function openReplyDialog(id) {

		var params = {
			url : '${params.contextPath}/view/icip/instruction/instruction_feedback_records.htm',
			title : '反馈记录查询',
			width : '800px',
			height : '90%'
		};
		params.url = $.getUrl(params.url, "id", id);
		DialogManager.openDialog(JSON.stringify(params).replace("{", "")
				.replace("}", ""));
	}
	function showDetail(index, row) {
		var url = "${params.contextPath}/view/icip/datareport/datareport_template_detail.htm?id="
				+ row.id;
		DialogManager.openDialog("url:'" + url
				+ "',title:'模板详情',width:'800px',height:'450px'");
	};
</script>
</html>
